package com.vitaf.cash.app.event.room;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * 数据库访问对象 DAO
 */
@Dao
public interface VitafPointDao {
    @Insert
    long insert(VitafEventPoint point);

    @Query("SELECT * FROM track_points WHERE status = 0 ORDER BY timestamp ASC")
    List<VitafEventPoint> getUnreportedPoints();

    @Query("DELETE FROM track_points WHERE id = :id")
    void deleteById(long id);

    @Update
    void update(VitafEventPoint point);

    @Query("DELETE FROM track_points WHERE status = 1")
    void deleteReportedPoints();

    @Query("SELECT COUNT(*) FROM track_points WHERE status = 0")
    int getUnreportedCount();
}
